<html>
<head><meta charset="utf-8"><title>compiler-builtins build fails in release mode · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html">compiler-builtins build fails in release mode</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227451360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227451360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227451360">(Feb 23 2021 at 15:48)</a>:</h4>
<p>I'm using <code>build-std</code> like this (contents of <code>.cargo/config.toml</code>):</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="p">[</span><span class="n">unstable</span><span class="p">]</span><span class="w"></span>
<span class="n">build</span><span class="o">-</span><span class="n">std</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="s">"core"</span><span class="p">,</span><span class="w"> </span><span class="s">"compiler_builtins"</span><span class="p">]</span><span class="w"></span>
<span class="n">build</span><span class="o">-</span><span class="n">std</span><span class="o">-</span><span class="n">features</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="s">"compiler-builtins-mem"</span><span class="p">]</span><span class="w"></span>
</code></pre></div>
<p>In debug mode, everything compiles just fine, but in release mode, the following error occurs when <code>compiler-builtins</code> is being built:</p>
<div class="codehilite"><pre><span></span><code>error: unknown flag
  |
note: instantiated into assembly here
 --&gt; &lt;inline asm&gt;:2:33
  |
2 |             .section .llvmbc,&quot;n&quot;
  |                                 ^
</code></pre></div>
<p>It appears several times with different line and column information but it doesn't report a specific file. <code>rg</code>ing through the entire <code>compiler-builtins</code> repo reveals that <code>.section</code> isn't present anywhere in the inline assembly blocks.</p>



<a name="227452379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227452379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227452379">(Feb 23 2021 at 15:53)</a>:</h4>
<p><code>.llvmbc</code> is the section that will contain the LLVM bitcode for LTO. What target are you compiling for?</p>



<a name="227452575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227452575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227452575">(Feb 23 2021 at 15:54)</a>:</h4>
<p>It's a custom target:</p>
<div class="codehilite" data-code-language="JSON"><pre><span></span><code><span class="p">{</span>
    <span class="nt">"llvm-target"</span><span class="p">:</span> <span class="s2">"x86_64-unknown-uefi"</span><span class="p">,</span>
    <span class="nt">"data-layout"</span><span class="p">:</span> <span class="s2">"e-m:e-i64:64-f80:128-n8:16:32:64-S128"</span><span class="p">,</span>
    <span class="nt">"arch"</span><span class="p">:</span> <span class="s2">"x86_64"</span><span class="p">,</span>
    <span class="nt">"target-endian"</span><span class="p">:</span> <span class="s2">"little"</span><span class="p">,</span>
    <span class="nt">"target-pointer-width"</span><span class="p">:</span> <span class="s2">"64"</span><span class="p">,</span>
    <span class="nt">"target-c-int-width"</span><span class="p">:</span> <span class="s2">"32"</span><span class="p">,</span>
    <span class="nt">"os"</span><span class="p">:</span> <span class="s2">"uefi"</span><span class="p">,</span>
    <span class="nt">"executables"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
    <span class="nt">"linker-flavor"</span><span class="p">:</span> <span class="s2">"ld.lld"</span><span class="p">,</span>
    <span class="nt">"linker"</span><span class="p">:</span> <span class="s2">"rust-lld"</span><span class="p">,</span>
    <span class="nt">"panic-strategy"</span><span class="p">:</span> <span class="s2">"abort"</span><span class="p">,</span>
    <span class="nt">"disable-redzone"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
    <span class="nt">"features"</span><span class="p">:</span> <span class="s2">"-mmx,-sse,+soft-float"</span><span class="p">,</span>
    <span class="nt">"default-hidden-visibility"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
    <span class="nt">"position-independent-executables"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
    <span class="nt">"exe-suffix"</span><span class="p">:</span> <span class="s2">".efi"</span><span class="p">,</span>
    <span class="nt">"is-like-windows"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
    <span class="nt">"emit-debug-gdb-scripts"</span><span class="p">:</span> <span class="kc">false</span>
<span class="p">}</span>
</code></pre></div>



<a name="227452771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227452771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227452771">(Feb 23 2021 at 15:55)</a>:</h4>
<p>Try disabling LTO.</p>



<a name="227453491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227453491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227453491">(Feb 23 2021 at 15:59)</a>:</h4>
<p>Trying to disable it via Cargo, this is my <code>Cargo.toml</code> for the workspace:</p>
<div class="codehilite" data-code-language="TOML"><pre><span></span><code><span class="k">[workspace]</span>
<span class="n">members</span> <span class="o">=</span> <span class="k">["kernel"]</span>

<span class="k">[profile]</span>
<span class="n">dev</span> <span class="o">=</span> <span class="p">{</span> <span class="n">panic</span> <span class="o">=</span> <span class="s">"abort"</span> <span class="p">}</span>
<span class="n">release</span> <span class="o">=</span> <span class="p">{</span> <span class="n">panic</span> <span class="o">=</span> <span class="s">"abort"</span><span class="p">,</span> <span class="n">lto</span> <span class="o">=</span> <span class="s">"off"</span> <span class="p">}</span>
</code></pre></div>
<p>The same error still gets produced, still only in <code>compiler-builtins</code>.</p>



<a name="227453904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227453904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227453904">(Feb 23 2021 at 16:00)</a>:</h4>
<p>setting <code>RUSTFLAGS</code> to <code>-C lto=off</code> could work, hold on</p>



<a name="227454072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227454072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227454072">(Feb 23 2021 at 16:01)</a>:</h4>
<p>nah, still the same error even with <code>-C lto=off</code></p>



<a name="227455117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227455117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227455117">(Feb 23 2021 at 16:04)</a>:</h4>
<p>setting <code>opt-level = 0</code> also doesn't fix it</p>



<a name="227455855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227455855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227455855">(Feb 23 2021 at 16:07)</a>:</h4>
<p>I found something though, setting <code>opt-level = 1</code> and <code>lto = true</code> in debug mode does trigger the error</p>



<a name="227466938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227466938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227466938">(Feb 23 2021 at 17:11)</a>:</h4>
<p>I fixed it by changing the target to <code>x86_64-unknown-uefi</code> instead of my own target, since that's probably more accurate anyway</p>



<a name="227466974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/compiler-builtins%20build%20fails%20in%20release%20mode/near/227466974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Goat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/compiler-builtins.20build.20fails.20in.20release.20mode.html#227466974">(Feb 23 2021 at 17:11)</a>:</h4>
<p>the old one was creating an ELF file by mistake, that may have been the problem</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>